class transCookie:
    def __init__(self, cookie):
        self.cookie = cookie

    def stringToDict(self):
        '''
        将从浏览器上Copy来的cookie字符串转化为Scrapy能使用的Dict
        :return:
        '''
        itemDict = {}
        items = self.cookie.split(';')
        for item in items:
            key = item.split('=')[0].replace(' ', '')
            value = item.split('=')[1]
            itemDict[key] = value
        return itemDict

if __name__ == "__main__":
    cookie = 'SXS_VISIT_XSESSION_ID_V3.0="2|1:0|10:1583836906|26:SXS_VISIT_XSESSION_ID_V3.0|48:YWE2YzRhNTItM2EyMS00M2M1LWI2ZTItODdlODM2NjgxZTYy|1795dc39944eb6e2f04f893876f81d91ad31d9ae55008f17a4c7928302a340ef"; SXS_XSESSION_ID="2|1:0|10:1583736117|15:SXS_XSESSION_ID|48:ODY2YTRlMjMtYjdlNi00NGU5LWE4NWUtY2VlN2Q3MTc0NWMx|7676458cc4c6036adc3450345a0477072bb94b44740068c5e7d8d85bb64c0899"; SXS_XSESSION_ID_EXP="2|1:0|10:1583736117|19:SXS_XSESSION_ID_EXP|16:MTU4MzgyMjUxNw==|bdeb651b5e5497f8d02bee38b767322a52d7b067c6a7cacc3b8c8a508ede23e2"; SXS_VISIT_XSESSION_ID_V3.0_EXP="2|1:0|10:1583836906|30:SXS_VISIT_XSESSION_ID_V3.0_EXP|16:MTU4NjQyODkwNg==|464fa559c5b16c11aaefbd0604dbe363ac310bd775595a93333e734a567eed2e"; gr_user_id=47edb63c-a7b5-4d10-8d39-53a9acb9edbe; __jsluid_s=f8924fc2713e7c26f1d1b2be7c6fe772; Hm_lvt_03465902f492a43ee3eb3543d81eba55=1583831511,1583831568,1583831601,1583832520; Hm_lpvt_03465902f492a43ee3eb3543d81eba55=1583836906; uuid=d2edeec4-115e-5c3f-94cd-3940aeaac07b; uid1=8dbe60ff-09ba-b4fe-af6e-0303f3ff8bb4; uid2=f5df6778-7871-5753-a3ed-26a2b39acb14; search=; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22170bf446add62-068d1edffa6d8c8-4c302879-1327104-170bf446ade68%22%2C%22%24device_id%22%3A%22170bf446add62-068d1edffa6d8c8-4c302879-1327104-170bf446ade68%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; MEIQIA_TRACK_ID=1YtLNGozFbmTnPINNiBdg6S3UUd; MEIQIA_VISIT_ID=1YvmOtmxCTgTu7nBokXjzduTrmb; sxs_usr="2|1:0|10:1583832405|7:sxs_usr|24:dXNyX2h5cXN3bjhvbmIxYQ==|dea68b37b7344c25a74fdc9c94417bbd03d10fc704740cff5afcca7b12ce4369"; userflag=user; affefdgx=usr_hyqswn8onb1a; xyz_usr="2|1:0|10:1583832405|7:xyz_usr|24:dXNyX2h5cXN3bjhvbmIxYQ==|f287bb3209771a6c1676424a11aad115685d389bc2448484c85a9a3e1f424a6d"; gr_session_id_96145fbb44e87b47=9f7adfc9-445d-4da9-8a85-bf87474bcd95; gr_session_id_96145fbb44e87b47_9f7adfc9-445d-4da9-8a85-bf87474bcd95=true; gr_cs1_9f7adfc9-445d-4da9-8a85-bf87474bcd95=user_id%3Ausr_hyqswn8onb1a'
    trans = transCookie(cookie)
    print (trans.stringToDict())